package com.ltu.mapper.customize;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ltu.domain.mp_entity.UserEntity;
import com.ltu.domain.mp_entity.customize.SessionInfoEntity;
import com.ltu.model.response.statistic.PubStatisticVO;
import com.ltu.model.response.statistic.SessionInfoStatisticVO;

/**
 * <p>
 * 会话表 Mapper 接口
 * </p>
 *
 * @author 若尘
 * @since 2024-10-17
 */
public interface SessionInfoMapper extends BaseMapper<SessionInfoEntity> {

	
	/**
	 * @Description: 根据设备id和会话领域统计对话
	 * @author 李生
	 * @date 2024-11-29 04:26:38 
	 * @return
	 */
	@Select(value = "SELECT   device_id,session_field_id,session_field,COUNT(1) as total from  tb_session_info ${ew.customSqlSegment}"
			+ " GROUP BY  device_id,session_field_id ")
	List<SessionInfoStatisticVO> countByDeviceAndfield(@Param(Constants.WRAPPER) Wrapper<SessionInfoEntity>  wrapper); 
	
	
	/**
	 * @Description: 统计来源设备的用户数
	 * @author 李生
	 * @date 2024-11-29 04:26:38 
	 * @return
	 */
	@Select(value = "SELECT   device_id,COUNT(1) as total from  sys_user ${ew.customSqlSegment}"
			+ " GROUP BY  device_id ")
	List<SessionInfoStatisticVO> countUserByDevice(@Param(Constants.WRAPPER) Wrapper<UserEntity>  wrapper); 
	
	
	@Select(value = "SELECT  account_id as id ,COUNT(*) as total  from  tb_session_info  WHERE  handle_flag = 0 and account_id > 0 "
			+ " GROUP BY  account_id  "
			+ "  ORDER BY total ASC ")
	List<PubStatisticVO> countField0ByAccount();
	
	
}
